import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Card, Badge } from 'antd';
import moment from 'moment';
import StandardTable from '@/components/StandardTable';

@connect(({ integratedqueryns, loading }) => ({
  loading: loading.models.integratedqueryns,
  supplierList: integratedqueryns.supplierList, // 报价单列表数据
}))
@Form.create()
class EmpInfor extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidMount() {}

  jumpRouting = (targetRouter, quoId) => {
    const { jumpRouting } = this.props;
    jumpRouting(targetRouter, quoId);
  };

  render() {
    const { supplierList, loading } = this.props;
    const columns = [
      {
        title: '协议名称',
        dataIndex: 'suppProtName',
        onHeaderCell: () => ({
          style: {
            fontWeight: 'bold',
            textAlign: 'left',
          },
        }),
        onCell: () => ({ style: { textAlign: 'left' } }),
      },
      {
        title: '服务产品',
        dataIndex: 'pdNameList',
        onCell: () => ({ style: { textAlign: 'left' } }),
        onHeaderCell: () => ({ style: { fontWeight: 'bold', textAlign: 'left' } }),
      },
      {
        title: '客户名称',
        dataIndex: 'custName',
        onCell: () => ({ style: { textAlign: 'left' } }),
        onHeaderCell: () => ({ style: { fontWeight: 'bold', textAlign: 'left' } }),
      },
      {
        title: '价格',
        dataIndex: 'price',
        onCell: () => ({ style: { textAlign: 'left' } }),
        onHeaderCell: () => ({ style: { fontWeight: 'bold', textAlign: 'left' } }),
      },
      {
        title: '状态',
        dataIndex: 'validFlag',
        onCell: () => ({ style: { textAlign: 'center' } }),
        onHeaderCell: () => ({ style: { fontWeight: 'bold', textAlign: 'center' } }),
        render(val) {
          return (
            <Badge status={val === 1 ? 'success' : 'error'} text={val === 1 ? '有效' : '已废弃'} />
          );
        },
        // render: (text, record) => {
        //   const yesor = record.payType;
        //   let name;
        //   if (yesor) {
        //     dictCode.PAY_FEES_WAY.map(c => {
        //       if (c.itemCode == yesor) {
        //         name = c.itemName;
        //       }
        //     });
        //   }
        //   return <span>{name}</span>;
        // },
      },
      {
        title: '创建时间',
        dataIndex: 'creTime',
        onCell: () => ({ style: { textAlign: 'left' } }),
        onHeaderCell: () => ({ style: { fontWeight: 'bold', textAlign: 'left' } }),
        render: text => text && moment(text).format('YYYY-MM-DD HH:mm'),
      },
      {
        title: '操作',
        dataIndex: 'operName',
        onCell: () => ({ style: { textAlign: 'center' } }),
        onHeaderCell: () => ({ style: { fontWeight: 'bold', textAlign: 'center' } }),
        render: (text, record) => (
          <span
            style={{ color: '#1890FF', cursor: 'pointer' }}
            onClick={() => this.jumpRouting('suppProtId', record.suppProtId)}
          >
            查看
          </span>
        ),
      },
    ];

    return (
      <div>
        <Card
          style={{ marginBottom: 12 }}
          title={<span style={{ fontWeight: 'bolder' }}>供应商协议</span>}
          bordered={false}
          extra={<a onClick={() => this.jumpRouting('suppProtId')}>更多&gt;&gt;</a>}
          id="supplierprotocol"
        >
          <StandardTable
            selectedRows={[]}
            selectedRowKeys={[]}
            rowSelection={null}
            loading={loading}
            data={supplierList}
            columns={columns}
            rowKey="suppProtId"
            pagination={false}
          />
        </Card>
      </div>
    );
  }
}
export default EmpInfor;
